package com.exam.api.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.exam.api.dao.ExamDetailDao;
import com.exam.api.dto.ExamDetailDTO;
import com.exam.api.service.ExamDetailService;
import com.exam.api.vo.InfoVO;
import com.exam.api.vo.QuestionVO;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @description: 分数详情业务层实现类
* @author: wuming
* @create: 2024.05.03 13:24:03
*/
@Service("examDetailService")
public class ExamDetailServiceImpl extends ServiceImpl<ExamDetailDao, ExamDetailDTO> implements ExamDetailService {

    @Override
    public Page<ExamDetailDTO> basePage(ExamDetailDTO examDetailDTO) {
        if (null != examDetailDTO.getCurrent() && null != examDetailDTO.getPageSize())
            examDetailDTO.setCurrent((examDetailDTO.getCurrent() - 1) * examDetailDTO.getPageSize());
        List<ExamDetailDTO> list = this.baseMapper.findList(examDetailDTO);
        int count = this.baseMapper.findPageCount(examDetailDTO);
        Page<ExamDetailDTO> page = new Page<>();
        page.setTotal(count);
        page.setRecords(list);
        return page;
    }

    @Override
    public List<ExamDetailDTO> findList(ExamDetailDTO examDetailDTO) {
        return this.baseMapper.findList(examDetailDTO);
    }

    @Override
    public List<InfoVO> getInfo(Long examId) {
          return this.baseMapper.getInfo(examId);
    }

    @Override
    public List<QuestionVO> getQuestion(Long examId) {
        return this.baseMapper.getQuestion(examId);
    }

}
